package xiaohu.ODImportant;

import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) {
            int n = scanner.nextInt();
            int count = 0;
            while (n > 1) {
                if (n % 3 == 0) {
                    count=count+n/3;
                    n=n/3;
                }else if (n % 3 == 1) {
                    count=count+n/3;
                    n=n/3+1;
                }else {
                    count=count+(n+1)/3;
                    n=(n+1)/3-1;
                }
            }
            if (count != 0) {
                System.out.println(count);
            }
        }
    }
}
